<?php
/**
 * Trainingofferadmin_Model_Trainingofferadmin
 *
 * @author adrian
 */
class Trainingofferadmin_Model_Trainingofferadmin implements Trainingofferadmin_Model_Mainable, Trainingofferadmin_Model_Decidable{
    
    public $action_handler;
    
    public function main(array $variables = null) {
        return $this->model_decision($variables);
    }

    public function model_decision(array $variables = null) {
        //var_dump($variables);
        //die();
        switch($variables['get']['name']){
            case "offers_list":
                return $this->offers_list($variables);
                break;
            case "add_new_offer":
                return $this->add_new_offer($variables);
                break;
            case "insert_new_offer":
                $this->insert_new_offer($variables['post']);
                break;
            case "edit_offer":
                return $this->edit_offer($variables);
                break;
            case "update_offer":
                $this->update_offer($variables['post']);
                break;
            case "delete_offer":
                $this->delete_offer($variables['post']);
                break;
        }
    }
    
    private function delete_offer(array $variables = null){
        $this->action_handler = new Trainingofferadmin_Model_Trainingofferdelete;
        $this->action_handler->main($variables);
    }
    
    private function update_offer(array $variables = null){
        $this->action_handler = new Trainingofferupdate_Model_Trainingofferupdate;
        $this->action_handler->main($variables);
    }
    
    private function edit_offer(array $variables = null){
        
    }
    
    private function insert_new_offer(array $variables = null){
        $this->action_handler = new Trainingofferadmin_Model_Inserttrainingoffert;
        $this->action_handler->main($variables);
    }
    
    private function add_new_offer(array $variables = null){
        $this->action_handler = new Trainingofferadmin_Data_Trainingofferadd;
        return $this->action_handler->main($variables);
    }
    
    private function offers_list(array $variables = null){
        //var_dump($variables);
        //die();
        $this->action_handler = new Trainingofferadmin_Data_Trainingofferslist;
        return $this->action_handler->main($variables);
    }
    
}
